<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############


class JFX_Module_Blockstyle_Property_Padding extends JFX_Module_Blockstyle_Property_Base
{

	public $id = 'padding';
	public $cssName = 'padding';
	public $title = 'Padding';

	public function init(){

		$paddingTop = new JFX_Module_Blockstyle_Widget_Slider($this);
		$paddingTop->name = 'Padding Top';
		$paddingTop->unit = JFX_Module_Blockstyle_Widget_Slider::$UNIT_PIXEL;
		$paddingTop->max = 300;
		$paddingTop->min = -50;
		$paddingTop->value = 0;
		$paddingTop->units[2] = 'auto';
		$paddingTop->unitNames[2] = 'Auto';
		$paddingTop->cssName = 'padding-top';
		$paddingTop->instanceId = $this->instanceId.'-paddingtop';
		$this->widgets[] = $paddingTop;


		$paddingRight = new JFX_Module_Blockstyle_Widget_Slider($this);
		$paddingRight->name = 'Padding Right';
		$paddingRight->unit = JFX_Module_Blockstyle_Widget_Slider::$UNIT_PIXEL;
		$paddingRight->max = 300;
		$paddingRight->min = -50;
		$paddingRight->value = 0;
		$paddingRight->units[2] = 'auto';
		$paddingRight->unitNames[2] = 'Auto';
		$paddingRight->cssName = 'padding-right';
		$paddingRight->instanceId = $this->instanceId.'-paddingright';
		$this->widgets[] = $paddingRight;

		$paddingBottom = new JFX_Module_Blockstyle_Widget_Slider($this);
		$paddingBottom->name = 'Padding Bottom';
		$paddingBottom->unit = JFX_Module_Blockstyle_Widget_Slider::$UNIT_PIXEL;
		$paddingBottom->max = 300;
		$paddingBottom->min = -50;
		$paddingBottom->value = 0;
		$paddingBottom->units[2] = 'auto';
		$paddingBottom->unitNames[2] = 'Auto';
		$paddingBottom->cssName = 'padding-bottom';
		$paddingBottom->instanceId = $this->instanceId.'-paddingbottom';
		$this->widgets[] = $paddingBottom;

		$paddingLeft = new JFX_Module_Blockstyle_Widget_Slider($this);
		$paddingLeft->name = 'Padding Left';
		$paddingLeft->unit = JFX_Module_Blockstyle_Widget_Slider::$UNIT_PIXEL;
		$paddingLeft->max = 300;
		$paddingLeft->min = -50;
		$paddingLeft->value = 0;
		$paddingLeft->units[2] = 'auto';
		$paddingLeft->unitNames[2] = 'Auto';
		$paddingLeft->cssName = 'padding-left';
		$paddingLeft->instanceId = $this->instanceId.'-paddingleft';
		$this->widgets[] = $paddingLeft;



	}






	

	public function __toCss(){
		$outputString = '';

		if(!$this->hasEnabledWidget()){
			return $outputString;
		}


		if(!$this->hasEnabledWidget() || $this->cssName=='' || $this->cssName != $this->id){
			return '/*not enabled '.$this->cssName.'*/ '.$outputString;
		}

		$paddingTopWidget = $this->getWidget($this->instanceId.'-paddingtop');
		$paddingBottomWidget = $this->getWidget($this->instanceId.'-paddingbottom');
		$paddingRightWidget = $this->getWidget($this->instanceId.'-paddingright');
		$paddingLeftWidget = $this->getWidget($this->instanceId.'-paddingleft');

		if($paddingTopWidget->enabled){
			if($paddingTopWidget->unit=='auto'){
				$cssValue = 'auto';
			}else{
				$cssValue = $paddingTopWidget->value.$paddingTopWidget->unit;
			}
			$outputString .= '	padding-top : '.$cssValue.";\n";
		}

		if($paddingBottomWidget->enabled){
			if($paddingBottomWidget->unit=='auto'){
				$cssValue = 'auto';
			}else{
				$cssValue = $paddingBottomWidget->value.$paddingBottomWidget->unit;
			}
			$outputString .= '	padding-bottom : '.$cssValue.";\n";
		}

		if($paddingLeftWidget->enabled){
			if($paddingLeftWidget->unit=='auto'){
				$cssValue = 'auto';
			}else{
				$cssValue = $paddingLeftWidget->value.$paddingLeftWidget->unit;
			}
			$outputString .= '	padding-left : '.$cssValue.";\n";
		}

		if($paddingRightWidget->enabled){
			if($paddingRightWidget->unit=='auto'){
				$cssValue = 'auto';
			}else{
				$cssValue = $paddingRightWidget->value.$paddingRightWidget->unit;
			}
			$outputString .= '	padding-right : '.$cssValue.";\n";
		}

		return $outputString;
	}










}





